[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>[#assign module]suits[/#assign][#assign moduleName="模板套件"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${base}/commonjs/flexgrid/css/flexigrid.pack.css" />

<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/flexgrid/js/flexigrid.js"></script>
<script type="text/javascript" src="${base}/commonjs/flexgrid/js/myflexigrid.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
<title>${moduleName}列表</title>
</head>
<body>
<table class="flexme3" style="display: none"></table>
<script type="text/javascript">
var grid = $(".flexme3").flexigrid(generateFlexGridCfg({
  title:'${moduleName}列表',
  url : '${base}/${module}/list',
  dataType : 'json',
  singleSelect: true,
  colModel:[
    ["ID", "id", 40, true, "asc",  "left", null],
    ["Name", "name", 100, true, "",  "left", null],
    ["Description", "description", 150, false, "",  "left", null],
    ["Operation", "description", 150, false, "",  "left", function(data, id, rowData){
      return ['<a href="javascript:addItem('+id+')">编辑</a>',
              '<a href="javascript:removeItem('+id+')">删除</a>',
              '<a href="javascript:showRenders('+id+')">渲染器配置</a>'
      ].join(" ");
    }]
  ],
  buttons: [
    ["添加${moduleName}", "add", addItem],
  ]
}));
function $1(id){
  return $("#"+id).val()
}
function flexGridReload(selector){
  $(selector).flexReload();
}
function addItem(id){
  var url = '${base}/${module}/add';
  if(id){
    url = '${base}/${module}/edit?id='+id;
  }
  var mode = id?"编辑":"添加新";
  art.dialog.open(url, {
    title: mode+'${moduleName}',
    background: '#EEE', // 背景色
    opacity: 0.05,  // 透明度
    width: 450,
    height: 350
  }).lock();
}
function showRenders(id){
	window.location.href = "${base}/suit/"+id+"/renders";
}
function removeItem(id){
  art.dialog({
    content: "确定要删除该${moduleName}【id="+id+"】？",
    title: "确认删除",
    icon: "question",
    background: '#EEE', // 背景色
    opacity: 0.05,  // 透明度
    lock: true,
    button: [{
      name: "确定",
      callback: function(){
        $.post("${base}/${module}/remove", {id: id}, function(text){
          var result = text;
          if(result.success){
            flexGridReload(".flexme3");
          }else{
            art.dialog({
    title: "删除失败",
    icon: "error",
    content: result.err,
    width: 400,
    height: 250,
    background: '#EEE', // 背景色
    opacity: 0.05,  // 透明度
    lock: true,
    ok: true
            });
          }
        });
      }
    }, {
      name: "取消",
      focus: true
    }]
  });
}

</script>

</body>
</html>